package com.frame.easy.modular.activiti.controller;

import com.frame.easy.base.controller.BaseController;
import com.frame.easy.result.Tips;
import org.activiti.engine.HistoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 流程相关变量
 *
 * @author tengchong
 * @date 2020/5/7
 */
@Controller
@RequestMapping("/auth/activiti/variable")
public class VariableController extends BaseController {

    @Autowired
    private HistoryService service;

    /**
     * 查询数据
     *
     * @param processInstanceId 流程实例ID
     * @return 数据
     */
    @RequestMapping("select")
    @ResponseBody
    public Tips select(String processInstanceId) {
        logger.debug("/auth/activiti/variable/select");
        return Tips.getSuccessTips(service.createHistoricVariableInstanceQuery().processInstanceId(processInstanceId).orderByVariableName().asc().list());
    }
}
